import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'

// 定义路由配置
const routes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login/index.vue'),
    meta: { title: '登录' }
  },
  {
    path: '/',
    name: 'Admin',
    component: () => import('../views/Manage/index.vue'),
    children: [
      {
        path: '/',
        name: 'ComputerRoom',
        component: () => import('../views/Manage/ComputerRoom/index.vue'),
        meta: { title: '机房管理' }
      },
      {
        path: 'home',
        name: 'Home',
        component: () => import('../views/Manage/Home.vue'),
        meta: { title: '主页' }
      },
      {
        path: 'about',
        name: 'About',
        component: () => import('../views/Manage/About.vue'),
        meta: { title: '关于' }
      },
      {
        path: 'user',
        name: 'UserManagement',
        component: () => import('../views/Manage/UserManagement.vue'),
        meta: { title: '用户管理' }
      }
    ]
  },
  // 404页面路由，需要放在最后
  {
    path: '/:pathMatch(.*)*',
    name: 'NotFound',
    component: () => import('../views/NotFound.vue'),
    meta: { title: '页面未找到' }
  }
]

// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router